package com.hippy.erya.config.interceptor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Autowired
    private GlobalProcessInterceptor globalProcessInterceptor;
    @Autowired
    private AccessLimitInterceptor accessLimitInterceptor;
    @Autowired
    private LogSaveInterceptor logSaveInterceptor;
    @Autowired
    private ReqValidityInterceptor reqValidityInterceptor;


    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //addPathPatterns()：需要拦截的访问路径，  excludePathPatterns()：不需要拦截的访问路径
        registry.addInterceptor(globalProcessInterceptor).addPathPatterns("/**").excludePathPatterns();

        registry.addInterceptor(logSaveInterceptor).addPathPatterns("/**");

        //请求拦截头部数据处理
        registry.addInterceptor(reqValidityInterceptor).addPathPatterns("/**").excludePathPatterns();
        //对查询接口访问请求限制拦截器
        registry.addInterceptor(accessLimitInterceptor).addPathPatterns("/query/**");
    }

}
